# Contributor: Ivan Tham <pickfire@riseup.net>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=opencc
pkgver=1.1.7
pkgrel=0
pkgdesc="Open Chinese Convert"
url="https://opencc.byvoid.com/"
arch="all"
license="Apache-2.0"
makedepends="
	cmake
	doxygen
	libmarisa-dev
	python3
	rapidjson-dev
	samurai
	tclap-dev
	"
checkdepends="
	benchmark-dev
	gtest-dev
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-libs
	"
source="https://github.com/BYVoid/OpenCC/archive/refs/tags/ver.$pkgver/OpenCC-ver.$pkgver.tar.gz"
builddir="$srcdir/OpenCC-ver.$pkgver"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_DOCUMENTATION=ON \
		-DBUILD_TESTING=OFF \
		-DUSE_SYSTEM_MARISA=ON \
		-DUSE_SYSTEM_RAPIDJSON=ON \
		-DUSE_SYSTEM_TCLAP=ON \
		-DUSE_SYSTEM_GOOGLE_BENCHMARK=ON \
		-DUSE_SYSTEM_GTEST=ON \
		-DENABLE_GTEST="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	./build/test/CommandLineConvertTest
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	mkdir -p "$pkgdir"/usr/share/doc
	mv "$pkgdir"/usr/share/opencc/doc "$pkgdir"/usr/share/doc/opencc
}

sha512sums="
26e4b12238f853b0fa91f9f0d9af7985bf04a0763185cc3b50b69ba99a2d80091b8c3160176d0d4cd348fbf1a680bfd80dc740dc60c938a256dc2dac8ef49f15  OpenCC-ver.1.1.7.tar.gz
"
